cmake_minimum_required(VERSION 3.0)

project(jsonparser)

if (NOT DEFINED ENV{X2500_TOOLCHAIN_PATH})
    message(FATAL_ERROR "
    FATAL: Cmake build failed. X2500_TOOLCHAIN_PATH Not found.
    ")
else()
    set(X2500_TOOLCHAIN_PATH $ENV{X2500_TOOLCHAIN_PATH})
    message("X2500_TOOLCHAIN_PATH = ${X2500_TOOLCHAIN_PATH}")
endif()

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER   $ENV{X2500_TOOLCHAIN_PATH}/mips-gcc-glibc/bin/mips-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER $ENV{X2500_TOOLCHAIN_PATH}/mips-gcc-glibc/bin/mips-linux-gnu-g++)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${compile_options} -Wall  -O2 -s -fsigned-char  -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${compile_options} -Wall  -O2 -s -fsigned-char  -fPIC -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${compile_options} -Wall  -O2 -s -fsigned-char  -fPIC -std=c++11")

set(SOURCES "main.c" "cJSON.c")

add_executable(jsonparser ${SOURCES})
